<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户注册 - 威客任务平台</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="/">威客任务平台</a>
            <div class="navbar-nav ms-auto">
                <a class="nav-link" th:href="@{/login}">登录</a>
                <a class="nav-link" th:href="@{/register}">注册</a>
            </div>
        </div>
    </nav>

    <div class="container mt-5">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <h3 class="text-center">用户注册</h3>
                    </div>
                    <div class="card-body">
                        <form th:action="@{/register}" th:object="${user}" method="post">
                            <div class="mb-3">
                                <label for="username" class="form-label">用户名</label>
                                <input type="text" class="form-control" id="username" th:field="*{username}" required>
                                <div class="text-danger" th:if="${usernameError}" th:text="${usernameError}"></div>
                            </div>
                            <div class="mb-3">
                                <label for="password" class="form-label">密码</label>
                                <input type="password" class="form-control" id="password" th:field="*{password}" required>
                            </div>
                            <div class="mb-3">
                                <label for="email" class="form-label">邮箱</label>
                                <input type="email" class="form-control" id="email" th:field="*{email}" required>
                                <div class="text-danger" th:if="${emailError}" th:text="${emailError}"></div>
                            </div>
                            <div class="mb-3">
                                <label for="phone" class="form-label">手机号</label>
                                <input type="text" class="form-control" id="phone" th:field="*{phone}">
                            </div>
                            <div class="mb-3">
                                <label for="role" class="form-label">角色</label>
                                <select class="form-control" id="role" th:field="*{role}">
                                    <option value="freelancer">威客</option>
                                    <option value="employer">雇主</option>
                                </select>
                            </div>
                            <div class="d-grid">
                                <button type="submit" class="btn btn-primary">注册</button>
                            </div>
                        </form>
                        <div class="text-center mt-3">
                            <a th:href="@{/login}">已有账户？立即登录</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>